<template>
  <div class="container">
    <el-form :model="searchList" ref="searchList">
      <el-row :gutter="20">
        <el-col :span="4" :offset="0">
          <el-form-item label="">
            <el-input v-model="searchList.name" placeholder="单位名称" clearable></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4" :offset="0">
          <el-form-item label="">
            <el-input v-model="searchList.projectName" placeholder="项目名称" clearable></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4" :offset="0">
          <el-form-item label="">
            <el-input v-model="searchList.ensure_dept" placeholder="保障部门" clearable></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="5" :offset="0">
          <el-select v-model="searchList.status" value-key="status" placeholder="请选择审核状态" class="wid">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="9" :offset="0">
          <div class="right">
            <el-button type="primary" size="medium" @click="search" :loading="loading">查询</el-button>
            <el-button type="primary" size="medium" @click="reset" :loading="loading">重置</el-button>
            <el-button type="primary" size="medium" @click="expExcel" :loading="loading">导出</el-button>
          </div>
        </el-col>
      </el-row>

    </el-form>
    <el-table :data="tableData.results" border stripe :height="offsetHeight" v-loading="loading">
      <el-table-column type="index" label="序号" width="40" align="center">
      </el-table-column>
      <el-table-column prop="departName" label="单位名称" width="150" align="center">
      </el-table-column>
      <el-table-column prop="ensure_dept" label="保障部门" width="150" align="center">
      </el-table-column>
      <el-table-column prop="projectName" label="项目名称" min-width="150" align="center">
      </el-table-column>
      <el-table-column prop="deviceCount" label="资产数量" min-width="40" align="center">
      </el-table-column>
      <el-table-column prop="servicePreAmount" label="申请金额(万元)" width="80" align="center">
      </el-table-column>
      <el-table-column prop="status" label="审核状态"  align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.status == 0">单位填报</span>
          <span v-if="scope.row.status == 1">本单位审核</span>
          <span v-if="scope.row.status == 2">保障部门审核</span>
          <span v-if="scope.row.status == 3">内设部门审核</span>
          <span v-if="scope.row.status == 51">电子政务部初审</span>
          <span v-if="scope.row.status == 4">咨询机构审核</span>
          <span v-if="scope.row.status == 52">电子政务部复审</span>
          <span v-if="scope.row.status == 6">上传审核报告</span>
        </template>
      </el-table-column>
      <el-table-column prop="nextDepartName" label="审核部门"   align="center">
      </el-table-column>
      <el-table-column prop="nextDepart" label="审核账号"   align="center">
      </el-table-column>
    </el-table>
    <div class="page">
      <el-pagination @size-change="pageSizeChange" @current-change="pageNoChange" :page-sizes="[10, 50, 100, 200]"
                     :page-size="10" background layout="total, sizes, prev, pager, next" :total="tableData.totalRecord">
      </el-pagination>
    </div>
  </div>
</template>
<script>
import ProjectItem from '@/components/Project'
import FlowItem from '@/components/FlowChart'
import { d_buildType } from '@/utils/dicts.js'
import { f_buildType, f_submitTtypeRename } from '@/utils/filters.js'
export default {
  name: 'UnitFinish',
  components: {
    ProjectItem, FlowItem
  },
  props: {
    switch: {
      type: Boolean,
      default: () => {
        return false
      }
    },
    status: {
      type: String,
      default: () => {
        return ''
      }
    },
  },
  data () {
    return {
      options: [{
        value: '0',
        label: '单位填报'
      }, {
        value: '1',
        label: '本单位审核'
      }, {
        value: '2',
        label: '保障部门审核'
      }, {
        value: '3',
        label: '内设部门审核'
      }, {
        value: '51',
        label: '电子政务初审'
      }, {
        value: '4',
        label: '咨询机构审核'
      }, {
        value: '52',
        label: '电子政务复审'
      }, {
        value: '6',
        label: '上传审核报告'
      }],
      offsetHeight: document.documentElement.clientHeight - 280,
      searchList: {},
      loading: false,
      tableData: [],
      pageNo: '1',
      pageSize: '10',
      projectShow: false,
      projectParams: {},
      d_buildType: d_buildType,
      flowShow: false,
      flowParams: {}
    }
  },
  created () {

  },
  mounted () {
  },
  methods: {
    async init () {
      this.loading = true
      const res = await this.$http('noFinishCountList2', {
        del_flag: '0',
        pageNo: this.pageNo,
        pageSize: this.pageSize,
        ...this.searchList
      })
      this.tableData = res;
      this.loading = false
    },
    expExcel () {
      let url = '/api/ac/maintain/infoProjectService/exportTotalData?a=b';
      let params = this.searchList;
      if(params.name != undefined) {
        url+= "&name="+params.name;
      }
      if(params.projectName != undefined) {
        url+= "&projectName="+params.projectName;
      }
      if(params.status != undefined) {
        url+= "&status="+params.status;
      }
      if(params.ensure_dept != undefined) {
        url+= "&ensure_dept="+params.ensure_dept;
      }
      window.open(url);
    },
    pageNoChange (pageNo) {
      this.pageNo = pageNo
      this.init()
    },
    pageSizeChange (pageSize) {
      this.pageSize = pageSize
      this.init()
    },
    search () {
      this.init()
    },
    reset () {
      this.pageNo ='1';
      this.pageSize='10';
      this.searchList =[];
      this.init()
    },
    cancel () {
      this.projectShow = false
      this.projectParams = {}
      this.contractShow = false
      this.contractParams = {}
    },
    projectInfo (pid) {
      this.projectShow = true
      this.projectParams = {
        pid: pid,
      }
    },
    contractInfo (item) {
      sessionStorage.setItem("inputInfo",
        JSON.stringify({
          switch: this.switch,
          pid: item.id,
          pcode: item.project_code,
          pname: item.project_name,
          path: 'finish'
        })
      );
      this.$router.push({
        path: './unit/contract',
      })
    },
    flow (item) {
      this.flowShow = true
      this.flowParams = {
        pid: item.id,
        status: item.status,
        apply_batch: item.apply_batch,
        inside_log: item.internal_code_log
      }
    }
  },
  computed: {

  },
  filters: {
    f_buildType: f_buildType,
    f_submitTtypeRename: f_submitTtypeRename
  }
}
</script>
<style scoped>
</style>
